// -*- coding: utf-8 -*- 
/**
 * Project: AlgorithmsLearn
 * Creator: yanking
 * Create time: 2022-02-23 21:19
 * IDE: IntelliJ IDEA
 * Introduction:
 */
package com.leetCode.findNthDigit;

public class findNthDigit_ {
    // 寻找规律数字序列中指定位数的数字字符
    public int findNthDigit(int n) {
        long k = n;
        int i = 1;
        while (true) {
            if (i * Math.pow(10, i) > k) {
                String s = k / i + "";
                return s.charAt((int) (k % i)) - '0';
            }
            k += Math.pow(10, i);
            i++;
        }
    }
}
